require "Dialogs"
Player.SetControlOverride(true)
Player.MoveToAbs(320, 160, false)

timer = 0

function Update()
	DialogUpdate()
	if timer == 0 then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,What]Realmente me\nvas a atacar?!", "rightwide", 490.5, 395, 40, 90, 1)
		else
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,What]Are you really\ngoing to attack\nme?!", "rightwide", 490.5, 395, 40, 90, 1)
		end
		timer = 1
	elseif timer == 1 and Bubbles[1] and not Bubbles[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,What]Cómo te atreves\na hacerme eso?! ", "rightwide", 490.5, 395, 40, 90, 1)
		else
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,What]How dare you do\nthat to me?! ", "rightwide", 490.5, 395, 40, 90, 1)
		end
		timer = 2
	elseif timer == 2 and Bubbles[1] and not Bubbles[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,Sad]Alguien que no\npuede defenderse\na sí mismo...", "rightwide", 490.5, 395, 40, 90, 1)
		else
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,Sad]Someone who\ncan't defend\nhimself...", "rightwide", 490.5, 395, 40, 90, 1)
		end
		timer = 3
	elseif timer == 3 and Bubbles[1] and not Bubbles[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Bubble("[noskip][font:papyrus][voice:papyrus]Pensé que eras\nalguien que aún\npodía cambiar.", "rightwide", 490.5, 395, 40, 90, 1)
		else
			Bubble("[noskip][font:papyrus][voice:papyrus]I thought you\nwere someone\nthat could\nstill change.", "rightwide", 490.5, 395, 40, 90, 1)
		end
		timer = 4
	elseif timer == 4 and Bubbles[1] and not Bubbles[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,Sad]Pero ahora veo\n[w:10]QUE [func:SetHead,Why]ESTABA\nEQUIVOCADO.[func:Trigger] ", "rightwide", 490.5, 395, 40, 90, 1)
		else
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,Sad]But now I see\n[w:10]THAT [func:SetHead,Why]I WAS WRONG.[func:Trigger] ", "rightwide", 490.5, 395, 40, 90, 1)
		end
		timer = 5
	elseif timer == 5 and Bubbles[1] and not Bubbles[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,Sad]TÚ ERES ALGUIEN\nQUE AMA HACER\nSUFRIR A LOS\nDEMÁS.", "rightwide", 490.5, 395, 40, 90, 1)
		else
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,Sad]YOU ARE JUST\nSOMEONE WHO\nLOVES TO MAKE\nOTHERS SUFFER.", "rightwide", 490.5, 395, 40, 90, 1)
		end
		timer = 6
	elseif timer == 6 and Bubbles[1] and not Bubbles[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,What]YA NI SÉ SI ERES\nUN HUMANO!", "rightwide", 490.5, 395, 40, 90, 1)
		else
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,What]I DON'T KNOW IF\nYOU ARE A HUMAN\nANYMORE!", "rightwide", 490.5, 395, 40, 90, 1)
		end
		timer = 7
	elseif timer == 7 and Bubbles[1] and not Bubbles[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,Why]ERES UN DEMONIO![func:Trigger][w:10]\n[func:SetHead,What]UN MAL PROBADOR\nDE ESPAGUETI![func:Trigger]", "rightwide", 490.5, 395, 40, 90, 1)
		else
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,Why]YOU ARE A DEMON![func:Trigger][w:10]\n[func:SetHead,What]A BAD SPAGHETTI\nTASTER![func:Trigger]", "rightwide", 490.5, 395, 40, 90, 1)
		end
		timer = 8
	elseif timer == 8 and Bubbles[1] and not Bubbles[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,Whatever]UN [w:30][waittall:4][func:SetHead,Sad]ASESINO DE\nHERMANOS.[func:Trigger]", "rightwide", 490.5, 395, 40, 90, 1)
		else
			Bubble("[noskip][font:papyrus][voice:papyrus][func:SetHead,Whatever]A [w:30][waittall:4][func:SetHead,Sad]DIRTY BROTHER\nKILLER.[func:Trigger]", "rightwide", 490.5, 395, 40, 90, 1)
		end
		timer = 9
	elseif timer == 9 and Bubbles[1] and not Bubbles[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Bubble("[noskip][font:papyrus][voice:papyrus]eres...[w:10] [func:SetHead,What]ERES...[w:10]\n[func:SetHead,Why]UN ASQUEROSO[w:10]\nPEDAZO[w:10] DE MIE[func:Trigger]RDA! ", "rightwide", 490.5, 395, 40, 90, 1)
		else
			Bubble("[noskip][font:papyrus][voice:papyrus]you're...[w:10] [func:SetHead,What]YOU'RE...[w:10]\n[func:SetHead,Why]A NASTY[w:10] PIECE[w:10] OF\nSH[func:Trigger]IT! ", "rightwide", 490.5, 395, 40, 90, 1)
		end
		timer = 10
	end
	if Encounter["Triggered"] then
		if not Played then
			NewAudio.PlaySound("Loop", "Predummy", true, 1)
			Played = true
		end
		Encounter["Triggered"] = nil
		Player.Hurt(0, 0.02)
		if timer < 10 then
			Shake = 0
			Player.hp = Player.hp - 20
		else
			Bubble("", "", "", "", "", "", 1)
			Encounter["X"] = Player.absx
			Encounter["Y"] = Player.absy
			Encounter["nextwaves"] = {"Game Over"}
			State("DEFENDING")
		end
	end
	if Shake then
		Shake = Shake + 1
		Player.MoveToAbs(320 + 6*math.sin(math.rad(360/10*Shake)), 160, false)
		if Shake == 10 then
			Shake = nil
		end
	end
end